<template>
  <div class="login-container">
    <br>
    <br>
    <br>
    <br>
    <br>
    <h1>xxx运动会管理系统</h1>
    <el-form
        :model="Loginform"
        status-icon
        ref="form"
        label-width="100px"
        class="login-form"
    >
      <h1 class="title-zc">登录页</h1>
      <el-form-item label="账号" prop="username">
        <el-input v-model.number="Loginform.username"></el-input>
      </el-form-item>

      <el-form-item label="密码" prop="password">
        <el-input
            type="password"
            v-model="Loginform.password"
            autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="info" @click="goReigster">去注册</el-button>
        <el-button type="primary" @click="submitForm">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "Login",
  data() {
    return {
      Loginform: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    submitForm() {
      this.axios.post('http://localhost:8901/user/login/',this.Loginform).then((resp)=>{
        let data = resp.data;
        console.log(data,"返回结果")
        if(data.success){
          this.$message({
            message: '恭喜你，操作成功',
            type: 'success'
          });
          this.$router.push({path: '/home'});
        }else {
          this.$message({
            message: data.message,
            type: 'error'
          });
        }
      })

    },
    goReigster(){
      this.$router.push('/register')
    }
  },
}
</script>

<style scoped>
.login-container {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: antiquewhite;
}
.login-form {
  width: 350px;
  margin: 150px auto;
  background-color: rgba(52, 115, 130, 0.7);
  padding: 30px;
  border-radius: 20px;
}
.title-zc {
  text-align: center;
}
</style>